<?php


namespace Framework;


use Closure;
use Illuminate\Http\Request;

class StoreMiddleware
{
    use Helper;
    /**
     * Handle an incoming request.
     *
     * @param Request $request
     * @param Closure $next
     *
     * @return mixed
     */
    public function handle($request, Closure $next)
    {

        $user_id = app(Jwt::class)->checkToken();

        $check = app(StoreCheck::class)->check_store($user_id);
        if (!$check) {
            $this->errorUnauthorizedStore();
        }

        return $next($request);
    }
}
